package com.itgaoshu.controller;

import com.itgaoshu.bean.Finance;
import com.itgaoshu.service.FinanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @author: xiyue
 * Date: 2021/3/22
 * Time: 15:30
 * To change this template use File | Settings | File Templates.
 * Description:
 */
@Controller
@RequestMapping("/finance")
public class FinanceController {
    //门诊月收入对比
    @Autowired
    private FinanceService financeService;
    @RequestMapping("/reportYearFinance")
    @ResponseBody
    public Object reportYearFinance(String year){
        List<Double> doubles = financeService.reportYearFinance(year);
        for (int i = 0; i < doubles.size(); i++) {
            if(null==doubles.get(i)) {
                doubles.set(i, 0.0);
            }
        }
        return doubles;
    }

    //住院月收入对比
    @ResponseBody
    @RequestMapping("zhuYuanYearFinance")
    public Object zhuYuanYearFinance(String year){
        List<Double> zhuYuan = financeService.zhuYuanYearFinance(year);
        for (int i = 0; i < zhuYuan.size(); i++) {
            if(null==zhuYuan.get(i)) {
                zhuYuan.set(i, 0.0);
            }
        }
        return zhuYuan;
    }
    //门诊年度统计
    @ResponseBody
    @RequestMapping("reportYearBingFinance")
    public Object reportYearBingFinance(){
        List<Finance> bingReport = financeService.reportYearBingFinance();
        System.out.println(bingReport);
        return bingReport;
    }
}
